package com.zsjt.app.compoent.exception;

import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;

import java.util.Map;
//给容器加入自己配置错误属性ErrorAttributes
@Component
public class MvcErrorAttributes extends DefaultErrorAttributes {
    //返回值的map就是页面和json能获取的字段
    @Override
    public Map<String, Object> getErrorAttributes(WebRequest webRequest, boolean includeStackTrace) {
        Map<String, Object> map =super.getErrorAttributes(webRequest, includeStackTrace);
        map.put("company","atguigu");
        //我们的异常处理器数据
        Map<String, Object> ext =( Map<String, Object>)webRequest.getAttribute("ext",0);
        map.put("ext",ext);
        return map;
    }
}
